﻿using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace InvestmentIntelligence.DbModel.Models.Mapping
{
    public class UsedSecurityMap : EntityTypeConfiguration<UsedSecurity>
    {
        public UsedSecurityMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.ClassId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.CurrencyId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.EconomicSectorId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.CountryId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.ParentId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Properties
            this.Property(t => t.Isin)
                .HasMaxLength(20);

            this.Property(t => t.Ric)
                .HasMaxLength(20);

            this.Property(t => t.Mic)
                .HasMaxLength(20);

            this.Property(t => t.Sedol)
                .HasMaxLength(20);

            this.Property(t => t.CustomIdentificator)
                .HasMaxLength(20);

            this.Property(t => t.ParentIdentify)
                .HasMaxLength(20);

            this.Property(t => t.ParentIdentifyType)
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("UsedSecurities", "MarketData");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Isin).HasColumnName("Isin");
            this.Property(t => t.Ric).HasColumnName("Ric");
            this.Property(t => t.Mic).HasColumnName("Mic");
            this.Property(t => t.Sedol).HasColumnName("Sedol");
            this.Property(t => t.CustomIdentificator).HasColumnName("CustomIdentificator");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.LongName).HasColumnName("LongName");
            this.Property(t => t.ClassId).HasColumnName("ClassId");
            this.Property(t => t.CurrencyId).HasColumnName("CurrencyId");
            this.Property(t => t.EconomicSectorId).HasColumnName("EconomicSectorId");
            this.Property(t => t.CountryId).HasColumnName("CountryId");
            this.Property(t => t.ParentId).HasColumnName("ParentId");
            this.Property(t => t.ParentIdentify).HasColumnName("ParentIdentify");
            this.Property(t => t.ParentIdentifyType).HasColumnName("ParentIdentifyType");
            this.Property(t => t.Type).HasColumnName("Type");
        }
    }
}
